package com.ax.base.common.service.impl;

import com.ax.base.common.dao.BaseChargeRulesMapper;
import com.ax.base.common.domain.BaseChargeRules;
import com.ax.base.common.service.BaseChargeRulesService;
import com.ax.base.common.utils.ErrorUtil;
import com.ax.base.common.utils.PageUtils;
import com.ax.base.common.utils.Query;
import com.ax.base.system.domain.SysUserDO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
public class BaseChargeRulesServiceImpl implements BaseChargeRulesService {

    @Autowired
    BaseChargeRulesMapper baseChargeRulesMapper;
    /**
     * 药店充值规则*添加新的规则
     * @param baseChargeRules
     * @return
     */
    @Override
    public int addBaseChargeRules(BaseChargeRules baseChargeRules) {
    //   Assert.notNull(baseChargeRules.getRegistrarId(),String.format(ErrorUtil.PARAMETER_NULL,"RegistrarId"));
   //    Assert.notNull(baseChargeRules.getRegistrarName(),String.format(ErrorUtil.PARAMETER_NULL,"RegistrarName"));
        return baseChargeRulesMapper.insert(baseChargeRules);
    }
    /**
     * 药店充值规则*更改规则
     * @param baseChargeRules
     * @return
     */
    @Override
    public int updateBaseChargeRules(BaseChargeRules baseChargeRules) {
     // Assert.notNull(baseChargeRules.getChargeRulesId(),String.format(ErrorUtil.PARAMETER_NULL,"ChargeRulesId"));
        return baseChargeRulesMapper.update(baseChargeRules);
    }

    /**
     * 药店充值规则*查询规则
     * @param baseChargeRules     flag不传查所有，传1查有效，传0查无效
     * @return
     */
    @Override
    public List<BaseChargeRules> queryList(Map<String, Object> params) {
    //	Query query = new Query(params);
		List<BaseChargeRules> BaseChargeRules = baseChargeRulesMapper.queryList(params);
	//	int total = baseChargeRulesMapper.count(query);
	//	PageUtils pageUtil = new PageUtils(BaseChargeRules, total);
		return BaseChargeRules;
    }

    /**
     * 药店充值规则*查询单条规则
     *
     * @param baseChargeRules
     * @return
     */
    @Override
    public BaseChargeRules query(BaseChargeRules baseChargeRules) {
        return baseChargeRulesMapper.query(baseChargeRules);
    }

    /**
     * 药店充值规则*删除规则
     * @param chargeRulesId
     * @return
     */
    @Override
    public int deleteBaseChargeRules(ArrayList<Long> chargeRulesId,Integer flag) {
        Assert.notNull(chargeRulesId,String.format(ErrorUtil.PARAMETER_NULL,"ChargeRulesId"));
        Assert.notNull(flag,String.format(ErrorUtil.PARAMETER_NULL,"flag"));
        return baseChargeRulesMapper.delete(chargeRulesId,flag);
    }
}
